package com.wuye.charge.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.wuye.common.annotation.Log;
import com.wuye.common.core.controller.BaseController;
import com.wuye.common.core.domain.AjaxResult;
import com.wuye.common.enums.BusinessType;
import com.wuye.charge.domain.WyCostMake;
import com.wuye.charge.service.IWyCostMakeService;
import com.wuye.common.utils.poi.ExcelUtil;
import com.wuye.common.core.page.TableDataInfo;

/**
 * 费用生成Controller
 * 
 * @author lishuo
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/charge/make")
public class WyCostMakeController extends BaseController
{
    @Autowired
    private IWyCostMakeService wyCostMakeService;

    /**
     * 查询费用生成列表
     */
    @PreAuthorize("@ss.hasPermi('charge:make:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestParam(value = "pageNum") int pageNum,
                              @RequestParam(value = "pageSize") int pageSize,
            @RequestBody WyCostMake wyCostMake
                              )
    {
        PageHelper.startPage(pageNum, pageSize);
        List<WyCostMake> list = wyCostMakeService.selectWyCostMakeList(wyCostMake);
        return getDataTable(list);
    }

    /**
     * 导出费用生成列表
     */
    @PreAuthorize("@ss.hasPermi('charge:make:export')")
    @Log(title = "费用生成", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyCostMake wyCostMake)
    {
        List<WyCostMake> list = wyCostMakeService.selectWyCostMakeList(wyCostMake);
        ExcelUtil<WyCostMake> util = new ExcelUtil<WyCostMake>(WyCostMake.class);
        util.exportExcel(response, list, "费用生成数据");
    }

    /**
     * 获取费用生成详细信息
     */
    @PreAuthorize("@ss.hasPermi('charge:make:query')")
    @GetMapping(value = "/{makeId}")
    public AjaxResult getInfo(@PathVariable("makeId") Long makeId)
    {
        return success(wyCostMakeService.selectWyCostMakeByMakeId(makeId));
    }

    /**
     * 新增费用生成
     */
//    @PreAuthorize("@ss.hasPermi('charge:make:add')")
//    @Log(title = "费用生成", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody WyCostMake wyCostMake)
//    {
//        return toAjax(wyCostMakeService.insertWyCostMake(wyCostMake));
//    }

    @PreAuthorize("@ss.hasPermi('charge:make:add')")
    @Log(title = "费用生成", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyCostMake wyCostMake)
    {
        return toAjax(wyCostMakeService.insertWyCostMake(wyCostMake));
    }



    /**
     * 修改费用生成
     */
    @PreAuthorize("@ss.hasPermi('charge:make:edit')")
    @Log(title = "费用生成", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyCostMake wyCostMake)
    {
        return toAjax(wyCostMakeService.updateWyCostMake(wyCostMake));
    }

    /**
     * 删除费用生成
     */
    @PreAuthorize("@ss.hasPermi('charge:make:remove')")
    @Log(title = "费用生成", businessType = BusinessType.DELETE)
	@DeleteMapping("/{makeIds}")
    public AjaxResult remove(@PathVariable Long[] makeIds)
    {
        return toAjax(wyCostMakeService.deleteWyCostMakeByMakeIds(makeIds));
    }
}
